import { ref, onMounted } from 'vue'
import { useRoute } from 'vue-router'
import { findSubCategoryFilter } from '@/api/category'
export function useLoadFilterData () {
  const subCategoryData = ref({})
  // 已选择标签 {[key]: value}
  const selectedTag = ref({})
  const route = useRoute()
  async function loadSubData () {
    const res = await findSubCategoryFilter(route.params.id)
    // console.log(res, 'jjj')
    subCategoryData.value = res.result
    for (const one of subCategoryData.value.saleProperties) {
      selectedTag.value[one.name] = null
    }
  }
  onMounted(() => {
    loadSubData()
  })
  return {
    subCategoryData,
    selectedTag
  }
}
